﻿using System;
using System.IO;
using System.Data.SqlTypes;
using sqlserverextensions.Helper;

    public partial class UserDefinedFunctions
    {
        [Microsoft.SqlServer.Server.SqlFunction]
        public static SqlBoolean FileRename(SqlString sourceFileName, SqlString destFileName)
        {
            Int16 errSeverity = 16;

            try
            {
                File.Move(sourceFileName.Value, destFileName.Value);
            }
            catch (Exception ex)
            {
                ExceptionHelper.EvaluateException(ex, errSeverity);
                return false;
            }

            return true;
        }
    }

